package com.tbit.main.service.impl;

import com.tbit.main.constant.DaoParamConstant;
import com.tbit.main.dao.core.AccountSmsModelDao;
import com.tbit.main.pojo.AccountSmsModel;
import com.tbit.main.service.AccountSmsModelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author LMY
 * @create 2020-11-17 17:17
 * 短信模板
 */
@Service("accountSmsModelService")
public class AccountSmsModelServiceImpl implements AccountSmsModelService {
    @Autowired
    private AccountSmsModelDao accountSmsModelDao;

    @Override
    public AccountSmsModel getByAccountIdAndType(Integer accountId, Integer smsType) {
        Map<String, Object> params = new HashMap<>();
        params.put(DaoParamConstant.accountId, accountId);
        params.put("smsType", smsType);
        return accountSmsModelDao.getByAccountIdAndType(params);
    }

    @Override
    public List<AccountSmsModel> getByAccountId(Integer accountId) {
        Map<String, Object> params = new HashMap<>();
        params.put(DaoParamConstant.accountId, accountId);
        return accountSmsModelDao.getByAccountId(params);
    }

    @Override
    public List<AccountSmsModel> getByAll(Integer smsType) {
        List<AccountSmsModel> accountSmsModelList = accountSmsModelDao.getByAll(smsType);
        for (AccountSmsModel accountSmsModel : accountSmsModelList) {
            if (accountSmsModel.getSmsCodeKey() == null || accountSmsModel.getSmsModelId() == null || accountSmsModel.getAccountId().equals(100019)) {
                accountSmsModel.setSmsCodeKey("5f272cb18fac070fbefb93121afc4916");
                accountSmsModel.setSmsModelId("92153");
            }
        }
        return accountSmsModelList;
    }

    @Override
    public List<AccountSmsModel> getSmsModelByAll() {
        return accountSmsModelDao.getSmsModelByAll();
    }
}
